package cn.sc.summer.calculate.enums;

import cn.hutool.core.util.StrUtil;
import cn.sc.summer.core.enums.SwaggerDisplayEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 枚举类型：任务行为枚举类
 *
 * @author a-xin
 * @date 10:38
 */
@Getter
@AllArgsConstructor
public enum TaskBehaviorEnum implements SwaggerDisplayEnum {

    PAUSE("1", "暂停", TaskStatusEnum.PAUSING),
    RESUME("2", "恢复", TaskStatusEnum.RUNNING),
    DELETE("3", "删除", TaskStatusEnum.DELETE),
    START("4", "启动", TaskStatusEnum.RUNNING),
    ADD("5", "新增", TaskStatusEnum.PAUSING),
    RUN_ONCE("6", "运行一次", TaskStatusEnum.PAUSING),
    ;

    private final String type;
    private final String info;
    private final TaskStatusEnum taskStatus;

    public static TaskBehaviorEnum getByType(String type) {
        if (StrUtil.isBlank(type)) {
            return null;
        }
        for (TaskBehaviorEnum enums : TaskBehaviorEnum.values()) {
            if (enums.type.equals(type)) {
                return enums;
            }
        }
        return null;
    }

}
